<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->title}</title>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/admin.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
th {text-align:right;}
td {text-align:left;}
-->
</style>
</head>
<body>
<div class="wrapper">
  <div class="title shadow titleBg">
    <table width="100%" border="0" cellspacing="1">
      <tr>
        <td><h1> {:$i->title} => {:if $i->p[0] eq "mod"}修改{:elseif $i->p[0] eq "add"}
    添加{:/if} </h1></td>
      </tr>
    </table>
  </div>
  <div class="content shadow">
    <form id="form1" method="post">
      <table width="100%" border="0" cellspacing="1">
        <tr>
          <th width="20%">上级栏目：</th>
          <td width="80%"><label>
            <select name="parentId" id="parentId" class="posted">
            <option value="0" {:if $i->data->parentId == 0}selected="selected"{:/if}>无(作为顶级栏目)</option>
            {:foreach item=item from=$i->categories}
            <option value="{:if $item->id == $i->data->id}-1{:else}{:$item->id}{:/if}" {:if $item->id == $i->data->parentId}selected="selected"{:/if}>{:$item->name}</option>
            {:/foreach}
            </select>
          </label></td>
        </tr>
        <tr>
          <th width="20%">栏目类型：</th>
          <td width="80%">
          <label>
              <input class="noBorder posted" name="type" type="radio" id="radio1" value="1" {:if 1 == $i->data->type}checked="checked"{:/if} />
              栏目列表 </label>
            &nbsp;&nbsp;
            <label><input class="noBorder posted" name="type" type="radio" id="radio2" value="2" {:if 2 == $i->data->type}checked="checked"{:/if} />
              栏目封面 </label>
            &nbsp;&nbsp;
            <label>
              <input class="noBorder posted"  type="radio" name="type" id="radio0" value="0" {:if 0 == $i->data->type}checked="checked"{:/if} />
              任意链接 </label></td>
        </tr>
        <tr>
          <th>栏目名称：</th>
          <td>
          <input name="name" type="text" size="20" id="name" value="{:$i->data->name}" class="posted check" /> *
          </td>
        </tr>
        <tr class="in">
          <th>栏目别名：</th>
          <td><input name="alias" type="text" size="30" maxlength="30" id="alias" value="{:$i->data->alias}" class="posted" /> 
          <input name="pinyin" id="pinyin1" type="radio" value="1" class="posted noBorder" /><label for="pinyin1">拼音</label>
          <input name="pinyin" id="pinyin2" type="radio" value="2" class="posted noBorder" /><label for="pinyin2">拼音首字母</label> 
          <input name="pinyin" id="pinyin3" type="radio" value="3" class="posted noBorder" checked="checked" /><label for="pinyin3">自定义</label>
           [<a href="#@" class="helpTip" title="允许字符：A-Z a-z 0-9 - _<br />别名主要用于URL中显示<br />默认为拼音">?</a>]
           </td>
        </tr>
        <tr class="in" id="channelIdTr">
          <th>绑定模型：</th>
          <td><label>
            <select name="channelId" id="channelId" class="posted check">
            {:foreach item=item key=key from=$i->channels}
            <option value="{:$key}" {:if $key == $i->data->channelId}selected="selected"{:/if}>{:$item.name}</option>
            {:/foreach}
            </select>
          </label> *</td>
        </tr>
       <tr class="in" id="categoryTemplateNameTr">
          <th>栏目模板：</th>
          <td>/template/{:$i->Load->var.style}/<input name="categoryTemplateName" type="text" id="categoryTemplateName" class="inputLine posted check" value="{:$i->data->categoryTemplateName}" size="30" />
            </td>
        </tr>
        <tr class="in" id="archiveTemplateNameTr">
          <th>默认文档模板：</th>
          <td>/template/{:$i->Load->var.style}/<input name="archiveTemplateName" type="text" id="archiveTemplateName" class="inputLine posted check" value="{:$i->data->archiveTemplateName}" size="30" />
            </td>
        </tr>
        <tr class="in" id="archiveUrlTr">
          <th>默认文档URL：</th>
          <td><input name="archiveUrl" type="text" id="archiveUrl" class="inputLine posted check" value="{:$i->data->archiveUrl}" size="40" />
          <label>
              <select name="regulation" id="regulation" onchange="$('#archiveUrl').val(this.value);">
              <option value="" selected="selected">URL参考规则</option>
              <option value="{:$i->Load->var.htmlSaveDir}/[alias]/%Y/%m%d/[id].html">栏目别名/年/月日</option>
              <option value="{:$i->Load->var.htmlSaveDir}/[alias]/%Y/%m/%d/[id].html">栏目别名/年/月/日</option>
              <option value="{:$i->Load->var.htmlSaveDir}/%Y/%m%d/[id].html">年/月日</option>
              <option value="{:$i->Load->var.htmlSaveDir}/%Y/%m/%d/[id].html">年/月/日</option>
              </select>
            </label> [<a href="#@" class="helpTip" title="[alias]表示当前的栏目别名<br />[id]表示文档ID<br />%Y%m%d用于格式化文档添加日期<br />%Y表示年,%m表示月,%d表示日">?</a>]
            </td>
        </tr>
        <tr class="in">
          <th><strong>列表访问：</strong></th>
          <td><input name="visit" id="visit1" type="radio" value="1" class="posted noBorder" {:if 1 == $i->data->visit}checked="checked"{:/if} /><label for="visit1">静态</label>
          <input name="visit" id="visit2" type="radio" value="2" class="posted noBorder" {:if 2 == $i->data->visit}checked="checked"{:/if} /><label for="visit2">动态</label> 
          <input name="visit" id="visit0" type="radio" value="0" class="posted noBorder" {:if '0' == $i->data->visit}checked="checked"{:/if} /><label for="visit0">自动</label>
          </td>
        </tr>
        <tr class="in">
          <th><strong>列表大小：</strong></th>
          <td><input name="pageSize" type="text" size="10" id="pageSize" value="{:$i->data->pageSize}" class="posted check" />  [<a href="#@" class="helpTip" title="栏目列表每页多少条记录">?</a>]</td>
        </tr>
        <tr>
          <th>导航显示：</th>
          <td>
            <label>
              <input class="noBorder posted"  type="radio" name="isHidden" value="0" {:if 0 == $i->data->isHidden}checked="checked"{:/if} />
              显示 </label> <label>
              <input class="noBorder posted"  type="radio" name="isHidden" value="1" {:if 1 == $i->data->isHidden}checked="checked"{:/if} />
              隐藏 </label>  [<a href="#@" class="helpTip" title="是否在导航中显示">?</a>]
            </td>
        </tr>
        <tr class="in">
          <th><strong>关键词：</strong></th>
          <td><input name="keywords" type="text" size="50" id="keywords" value="{:$i->data->keywords}" class="posted" /></td>
        </tr>
        <tr class="in">
          <th><strong>描　述</strong>：</th>
          <td><textarea name="desc" rows="3" id="desc" class="posted">{:$i->data->desc}</textarea></td>
        </tr>
        <tr class="out">
          <th>链接地址：</th>
          <td><input name="link" type="text" size="60" id="link" value="{:$i->data->link}" class="posted check" /></td>
        </tr>
        <tr>
          <th>&nbsp;</th>
          <td><input type="submit" value=" 提 交 " />
            &nbsp;
            <input type="reset" onclick="history.go(-1);" value=" 返 回 " />          </td>
        </tr>
      </table>
    </form>
  </div>
</div>	
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/tooltip.css" rel="stylesheet" type="text/css" />
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/ui.all.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.core.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.draggable.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.dialog.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.post.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.tooltip.js"></script>
<script language="javascript" type="text/javascript">
	
var typeId = $("input:checked[name='type']").val();
switch(typeId)
{
	case '1':$("#archiveTemplateNameTr,#pageSizeTr,#archiveUrlTr,#channelIdTr").show();$(".out").hide();break;
	case '2':$("#archiveTemplateNameTr,#pageSizeTr,#archiveUrlTr,#channelIdTr,.out").hide();break;
	case '0':$(".in").hide();$(".out").show();break;
}

var channel = new Array();
{:foreach item=item key=key from=$i->channels}
channel[{:$key}] = "{:$item.tableId}";
{:/foreach}
	
$(document).ready(function(){
	
	$("form").post({
		sendUrl:'{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/{:if $i->p[0] eq "mod"}update/{:$i->p[1]}{:elseif $i->p[0] eq "add"}insert{:/if}',
		goUrl:'{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/lists/-1'
	});

	$("#parentId").change(function(){
		if(this.value == -1)
		{
			alert('不能选择自身ID');
			this.value = 0;
			return false;
		}
	});
	
	$("input[name='pinyin']").click(function(){
		if(this.value == 3)
		{
			$("#alias").show();
		}
		else
		{
			$("#alias").hide();
		}
	});

	$("input[name='type']").click(function(){
		var channelId = $("#channelId").val();
		
		if(this.value == 1)
		{
			var categoryTemplate = (channelId > 0) ? channel[channelId]+'List' : 'list';
			var archiveTemplate = (channelId > 0) ? channel[channelId]+'Show' : 'show';
			$(".in").show();
			$(".out").hide();
			if($("#categoryTemplateName").val() == '') $("#categoryTemplateName").val(categoryTemplate+'.tpl');
			if($("#archiveTemplateName").val() == '') $("#archiveTemplateName").val(archiveTemplate+'.tpl');
			$("#archiveTemplateNameTr,#archiveUrlTr,#channelIdTr").show();
		}
		else if(this.value == 2)
		{
			$(".in").show();
			$(".out").hide();
			$("#archiveTemplateNameTr,#archiveUrlTr,#channelIdTr").hide();
		}
		else if(this.value == 0)
		{
			$(".in").hide();
			$(".out").show();
		}				   							   
	});
	
	$("#channelId").change(function(){
		var typeId = $("input:checked[name='type']").val();
		if(confirm('是否自动更新栏目模板和文档默认模板？'))
		{
			if(typeId == 1)
			{
				var categoryTemplate = (this.value > 0) ? channel[this.value]+'List' : 'list';
				var archiveTemplate = (this.value > 0) ? channel[this.value]+'Show' : 'show';
				$("#categoryTemplateName").val(categoryTemplate+'.tpl');
				$("#archiveTemplateName").val(archiveTemplate+'.tpl');
				$("#archiveTemplateNameTr,#pageSizeTr,#archiveUrlTr,#channelIdTr").show();
			}
			else if(typeId == 2)
			{
				var value = (this.value > 0) ? channel[this.value]+'Index' : 'index';
				$("#categoryTemplateName").val(value+'.tpl');
				$("#archiveTemplateNameTr,#pageSizeTr,#archiveUrlTr,#channelIdTr").hide();
			}
		}
	});
	
	$(".helpTip").tooltip({cssClass:"tooltip", xOffset:30, opacity:5});
});


</script>
</body>
</html>